home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: C code in a C++ app
- Date: 3 Mar 1996 12:03:05 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4hc1pp$1eu@news1.usa.pipeline.com>
- References: <4hbddg$899@sam.inforamp.net>
- NNTP-Posting-Host: pipe9.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 03, 1996 06:15:22 in article <Re: C code in a C++ app>,
- 'rmorin@inforamp.net (Randy Charles Morin)' wrote:
-
-
- >In article <4h7t43$6as@frodo.smartlink.net>,
- >thomash@warp10.smartlink.net (Thomas Hackbarth) wrote:
- >>I'm working on porting a C app. from MAC to the PC. The app is basicly C
-
- >>and I'm replacing the UI for the PC side. I need to compile and link C
- >>code into my MFC application. I get errors basicly saying I can't compile
-
- >>C code with CPP, OK I renamed the file to CPP then I need to add #include
-
- >><stdafx.h>. I would rather not change any of the C files at all. They
- >>need to stay multiplatform as well as multi-compiler.
- >>
- >>Does anyone know how to build a MCF app with C code, with out changing
- >>the C code.
- >
- >Change your function headers to
- > extern "C" void _export PayrollProcess(PAYROLLPROCESS * B)
- >from
- > void _export PayrollProcess(PAYROLLPROCESS * B)
- >
- >This tells the compiler that your C++ code is really C code.
- >
- Unfortunately, this answer is not to the question asked. (Aside from
- possibly being wrong). The _export keyword is not used in MSVC++4.0,
- which, if I remember correctly, was specified in the original post. But
- it's a moot point since it is used only in DLLs, which is not the subject
- of the question.
-
- The correct answer is to leave the C code with extension .c, omit the
- inclusion of <stdafx.h>, and change the compiler option switches
- pertaining to precompiled headers. The use of extern "C", of course, is
- appropriate.
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-